/*
 * @Description: 你的代码我的心
 * @Author: GGB
 * @Date: 2022-06-01 13:45:31
 * @LastEditors: GGB
 * @LastEditTime: 2022-06-01 18:09:50
 */
import 'package:flutter/material.dart';
import 'package:flutter_email_ui/components/side_menu.dart';
import 'package:flutter_email_ui/screens/email/demo_first.dart';
import 'package:flutter_email_ui/screens/email/demo_second.dart';
import 'package:flutter_email_ui/screens/email/email_screen.dart';
import 'package:flutter_email_ui/screens/main/components/list_of_emails.dart';
import 'package:get/get.dart';

import '../../controller/controller.dart';
import '../../responsive.dart';

class MainScreen extends StatefulWidget {
  MainScreen({Key key}) : super(key: key);

  @override
  State<MainScreen> createState() => _MainScreenState();
}

class _MainScreenState extends State<MainScreen> {
  final controller = NavController();
  @override
  Widget build(BuildContext context) {
    Size _size = MediaQuery.of(context).size;
    return Scaffold(
      body: Responsive(
        mobile: ListOfEmails(),
        tablet: Row(
          children: [
            Expanded(
              flex: 6,
              child: ListOfEmails(),
            ),
            Expanded(
              flex: 9,
              child: GetX<NavController>(
                init: controller,
                initState: (_) {},
                builder: (_) {
                  print(_.nav);
                  if (_.nav == 0) return DemoFirst();
                  if (_.nav == 1) return DemoSecond();
                  return EmailScreen();
                },
              ),
            ),
          ],
        ),
        desktop: Row(children: [
          Expanded(
            flex: _size.width > 1340 ? 2 : 4,
            child: SideMenu(),
          ),
          Expanded(
            flex: _size.width > 1340 ? 3 : 5,
            child: ListOfEmails(),
          ),
          Expanded(
            flex: _size.width > 1340 ? 8 : 10,
            child: GetX<NavController>(
              init: controller,
              initState: (_) {},
              builder: (_) {
                print(_.nav);
                if (_.nav == 0) return DemoFirst();
                if (_.nav == 1) return DemoSecond();
                return EmailScreen();
              },
            ),
          ),
        ]),
      ),
    );
  }
}
